package com.f1ashback.bus.controller;

import com.f1ashback.bus.Vo.NoticeVo;
import com.f1ashback.bus.common.AjaxResult;
import com.f1ashback.bus.service.NoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/notice")
@CrossOrigin(origins = "*", maxAge = 3600)
public class NoticeController {

    @Autowired
    private NoticeService noticeService;

    @GetMapping("/applist")
    public List<NoticeVo> applist(){
        return noticeService.applist();
    }

    @PostMapping("/pubNotice")
    public AjaxResult pubNotice(@RequestBody String noticeD){
        return noticeService.pubNotice(noticeD);
    }

    @GetMapping("/list")
    public AjaxResult list(){
        return noticeService.listNotice();
    }

    @DeleteMapping("/del/{noticeId}")
    public AjaxResult deleteNotice(@PathVariable Long noticeId){
        return noticeService.deleteNotice(noticeId);
    }

    @PutMapping("/update")
    public AjaxResult update(@RequestBody NoticeVo noticeVo){
        return noticeService.updateNotice(noticeVo);
    }
}
